const { DataTypes, STRING } = require("sequelize");
const sequelize = require("../db/seq");
const moment = require("moment")
const Talk = sequelize.define("talk", {
  id: {
    type: DataTypes.INTEGER,
    autoIncrement: true,
    primaryKey: true,
  },
  content:{
    type:DataTypes.STRING,
  },
  createTime: {
    type: DataTypes.STRING,
  },
  forumId: {
    type: DataTypes.INTEGER,
  },
  groupId: {
    type: DataTypes.INTEGER,
  },
  imgUrl: {
    type: STRING,
  },
  istop: {
    type: DataTypes.INTEGER,
  },
  link: {
    type: DataTypes.STRING,
  },
  replyId:{
    type:DataTypes.INTEGER
  },
  userId:{
    type:DataTypes.INTEGER
  }
},{
    tableName:"bl-talk",
    timestamps:true,
    createdAt:"createTime",
    updatedAt:false,
    hooks: {
      beforeValidate: (instance, options) => {
        if (instance.createTime instanceof Date) {
          instance.createTime = moment(instance.createTime).valueOf()+""
        }
      }
    }
});

module.exports = Talk;
